package requests

import (
	"github.com/flaravel/quanlaolao/app/models/channel"
	"github.com/thedevsaddam/govalidator"
)

func ValidateChannelForm(data channel.Channel) map[string][]string {

	rules := govalidator.MapData{
		"name": []string{"required", "max_cn:10"},
	}

	messages := govalidator.MapData{
		"title": []string{
			"required:渠道名称为必填项",
			"max_cn:渠道名称长度需小于 10",
		},
	}

	opts := govalidator.Options{
		Data:          &data,
		Rules:         rules,
		TagIdentifier: "valid", // 模型中的 Struct 标签标识符
		Messages:      messages,
	}

	return govalidator.New(opts).ValidateStruct()
}